﻿using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;

namespace Gmantis.Controls.DataGrid
{
    public class DataGridRowError
    {
        // Methods
        public DataGridRowError()
        {
            this.Message = "";
            this.ColumnNames = new List<string>();
        }

        public DataGridRowError(ValidationResult validationResult)
        {
            this.Message = validationResult.ErrorMessage;
            this.ColumnNames = validationResult.MemberNames.ToList<string>();
        }

        public DataGridRowError(string message)
        {
            this.Message = message;
            this.ColumnNames = new List<string>();
        }

        public DataGridRowError(string message, IEnumerable<string> members)
        {
            this.Message = message;
            this.ColumnNames = (members != null) ? members.ToList<string>() : new List<string>();
        }

        // Properties
        [TypeConverter(typeof(StringListConverter))]
        public List<string> ColumnNames { get; set; }

        public string Message { get; set; }
    }
}
